1. Field of the Invention
The present invention relates to the handling of a non-preemptive system resource when a thread using the non-preemptive system resource is preempted.
2. Background of the Related Art
When a thread needs to use a system level resource, a locking mechanism is used to prevent other threads from reclaiming the resource. However, it may not be feasible in all circumstances to use a lock. For example, in a tracing tool, where the target process is patched, the patched code is a non-preemptive system wide resource, because, when the process is executing the patch, it is expected that the patched code is not removed. Currently, it is necessary to prevent removing of the patched code when the thread is running. However, there is nothing to prevent a thread running in the patched code from being dispatched out. If a thread is preempted out while running in the patched code, the thread will core dump on dispatch if the resource is freed.